import * as API_Trade from '../../api/trade'
Page({

  /**
   * 页面的初始数据
   */
  data: {
    //订单编号
    sn: '',
    //接收参数
    express:'',
    //物流信息
    logisticsData: '',
    //收货地址
    address: '',
    is_jd_order: ''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log('options',options);
    this.setData({
      is_jd_order: options.is_jd_order
    })
    const {sn} = options
    this.getLogistisc(sn)
    this.setData({
      sn: sn
    })
    this.setData({
      address: options.address
    })
  },
  // 请求京东物流信息
  getLogistisc(sn){
    API_Trade.getLogistisc(sn).then(response=>{
      console.log('response',response);
      this.setData({express:response})
      console.log('express',this.data.express[0].sku);
    })
  },
  btnTo: function(item){
    var arr = JSON.stringify(item.currentTarget.dataset.bean)
    console.log('arr',arr);
    wx.navigateTo({
      url: '/ucenter/express/express?logistics=' + arr + '&&address=' + this.data.address + '&&sn=' + this.data.sn + '&&is_jd_order=' + this.data.is_jd_order,
    })
  }
})
